package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    //是全局的catch方法
    @ExceptionHandler(Exception.class)
    public Result exceptionMethod(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(MyException.class)
    public Result exceptionMethod2(){
        return Result.fail(201,"文件太大");
    }

    @ExceptionHandler(LeaseException.class)
    public Result exceptionMethod3(LeaseException e){
        return Result.fail(e.getCode(),e.getMessage());
    }
}